package com.jml.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.jml.bean.Depart;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("departServiceImpl")
public class DepartServiceImpl implements DepartService {


    @Override
    public boolean saveDepart(Depart depart) {
        return false;
    }

    @Override
    public boolean removeDepartById(int id) {
        return false;
    }

    @Override
    public boolean modifyDepart(Depart depart) {
        return false;
    }

    @Override
    public Depart getDepartById(int id) {
        try {
            Thread.sleep(2000);//休眠2000毫秒
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        if (id ==1){
            throw new RuntimeException("There is a bugger~~~~");
        }
        Depart depart = new Depart(1,"");
        depart.setName("no this depart");
        return depart;
    }

    @Override
    public List<Depart> listAllDeparts() {
        return null;
    }


    @Override
    public List<Depart> lianlu() {
        List<Depart> list = new ArrayList<>();
        list.add(new Depart(1,"链路限流"));
        return list;
    }

    public List<Depart> lianluQpsFlowRuleFallback() {
        List<Depart> list = new ArrayList<>();
        list.add(new Depart(0,"进入熔断方法"));
        return list;
    }
}
